package cn.ljy.authority.web.controller.backstage.authority;


import cn.ljy.authority.model.SysConfig;
import cn.ljy.authority.model.SysRole;
import cn.ljy.authority.model.param.RoleEnabledParam;
import cn.ljy.authority.model.param.RolePermissionParam;
import cn.ljy.authority.model.query.SysConfigQuery;
import cn.ljy.authority.model.query.SysRoleQuery;
import cn.ljy.authority.service.SysRoleService;
import cn.ljy.authority.web.controller.backstage.BaseBackstageController;
import cn.ljy.common.model.result.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Api(tags = "后台网站配置模块")
@RestController
@RequestMapping(value = "/api/backstage/authority/config")
public class SysConfigController extends BaseBackstageController<SysConfig, SysConfigQuery,Integer> {

    @Autowired
    private SysRoleService baseService;

    @PreAuthorize("hasAuthority('sys:role:query')")
    @GetMapping("/all")
    @Override
    public ResponseData query(SysConfigQuery sysConfigQuery){
        return super.query(sysConfigQuery);
    }


    @ApiOperation(value = "分页查询网站配置列表")
    @PreAuthorize("hasAuthority('sys:role:query')")
    @Override
    public ResponseData query(Integer page, Integer pageSize, SysConfigQuery sysConfigQuery){
        return super.query(page,pageSize,sysConfigQuery);
    }


    @ApiOperation(value = "批量删除指定的多个配置")
    @PreAuthorize("hasAuthority('sys:role:del')")
    @Override
    public ResponseData deletes(@NotEmpty(message="请选择要移除的记录")Integer[] ids){
        return super.deletes(ids);
    }

    @ApiOperation(value = "读取指定配置信息")
    @PreAuthorize("hasAuthority('sys:role:query')")
    @Override
    public ResponseData get(@PathVariable Integer id) {
        return super.get(id);
    }

    @ApiOperation(value = "编辑配置")
    @PreAuthorize("hasAuthority('sys:role:edit')")
    @Override
    public ResponseData edit(@Valid @RequestBody SysConfig sysConfig){
        return super.edit(sysConfig);
    }

    @ApiOperation(value = "添加网站配置")
    @PreAuthorize("hasAuthority('sys:role:add')")
    @Override
    protected ResponseData add(@Valid @RequestBody SysConfig sysConfig) {
       return super.add(sysConfig);
    }


}
